Refactor into opencartograph package with enhancements#2
Merged
Conversation
Extract the 1051-line create_map_poster.py into a proper Python package with clear module boundaries, frozen dataclasses, a composable rendering pipeline, and 85 unit tests — while keeping all CLI arguments identical. Key changes: - New maptoposter/ package with 17 modules organized by responsibility - Frozen dataclasses (Theme, PosterConfig, Coordinates, FontSet) replace raw dicts, eliminating global mutable state (THEME, FONTS) - Composable render pipeline: adding a new map layer = one function - Duplicate road classification merged into single-pass compute_edge_styles() - 85 pytest tests covering models, cache, text, themes, CLI, road styles - Full type annotations (mypy clean), flake8 clean - Backward-compatible shims: python create_map_poster.py still works - python -m maptoposter and pip-installed `maptoposter` CLI entry point - CI updated with pytest step Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Merge upstream PR originalankur#209: extract monolithic create_map_poster.py into a proper Python package with 17 modules, frozen dataclasses, composable render pipeline, and 85 unit tests - Rename package from maptoposter to opencartograph - Remove backward-compat shims (create_map_poster.py, font_management.py) - Add --no-text flag for generating posters without text overlay - Enable OSMnx caching (ox.settings.use_cache) for faster repeat runs - Expand park/green space tags to include cemeteries and woodland - Update CLI branding, examples, and help text for OpenCartograph - Rewrite README for new package structure
Narrow broad exception handlers to specific exception types across osm, fonts, layers, and theme modules. Bump version to 0.4.0 to avoid collision with upstream 0.3.0. Add missing tests for --no-text flag and compose_poster typography conditional. Fix stale user_agent, CHANGELOG, README pip instructions, and consolidate duplicate dev dependencies.
The exceptions exist in osmnx._errors but aren't re-exported at the top-level namespace in osmnx 2.0.7.
Replace only os.sep with a full character sanitizer that keeps alphanumerics, dots, hyphens, and underscores. This prevents forward slashes in cache keys from creating nested paths on Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
create_map_poster.pyinto a proper Python package with 17 modules, frozen dataclasses, composable render pipeline, and 85 unit testsmaptopostertoopencartographcreate_map_poster.py,font_management.py)--no-textflag for generating posters without text overlayox.settings.use_cache) for faster repeat runsTest plan
opencartograph --list-themesworksopencartograph --helpshows--no-textflaguv syncinstalls asopencartograph==0.3.0maptoposterin.py,.toml, or.ymlfiles